layui.config({
  base: '/layui_exts/' //设定扩展的Layui模块的所在目录，一般用于外部模块扩展
}).extend({
	dynamicCondition: 'dynamicCondition/dynamicCondition'
}).use(['table','form'], function(){
	var $=layui.$, table = layui.table, form = layui.table;
	var dynamicCondition = layui.dynamicCondition;
	
	var dataFields = [{field:"id",title:"id",edit:"text",layVerify:"number"}
		,{field:"name",title:"姓名",edit:"text"}
		,{field:"sex",title:"性别",edit:"select", templet:"#selectSex"}
		,{field:"birthday",title:"出生日期",edit:"date"}
		,{field:"phone",title:"手机号码",edit:"text",layVerify:"phone"}
		,{field:"email",title:"邮箱",layVerify:"email"}
		];
	//初始化动态条件查询实例

	
	
	var complexDc = dynamicCondition.create({elem:"#dcDemo" //通过容器选择器传入，也可以$("#dcDemo"),或者document.getElementById("dcDemo")
	  	//,tableId:"listTable" //静态页面不好演示table数据表格更新
	  	,type:"complex"  //type:"simple"/"complex"
		,conditionTextId:"#msg2"
		//当有多个动态条件查询实例时，定义instanceName属性可以通过dynamicCondition.getInstance(instanceName)获取对应的实例
		,instanceName:  "complexInstance"  
		,queryCallBack:function(requestData){
			$("#result2").html(JSON.stringify(requestData));
		}
	});
	complexDc.setCondition([["name","like","张三"],["sex",null,"1"],["birthday","between","2018-01-01","2018-12-31"]]);
	$("#result2").html(JSON.stringify(complexDc.buildRequestData()));
	/**复杂查询*/
	$("#complexBtn").on("click",function(){
		dynamicCondition.getInstance("complexInstance").open();
	})
	

	
	
});




layui.use([ 'form', 'table', 'laydate','layer','element'], function () {
        var form = layui.form,
            table=layui.table,
            laydate = layui.laydate,
            $ = layui.jquery,
            layer = layui.layer,
            element = layui.element;

       
    	//零售小票选择时间
var curDate = new Date();
	 laydate.render({
    elem: '#test1' //指定元素
    ,value: new Date(curDate.getTime() - 24*60*60*1000*2) //前两天
  });
  laydate.render({
    elem: '#test2' //指定元素
    ,value: new Date() //
  });
    laydate.render({
    elem: '#date' //指定元素
  });    
  
  $('.gk_zuzhi').on('click', function(){
    parent.layer.open({
	    type: 2,
	    title: '组织选择',
	    maxmin: true,
	    moveOut: true,
	    area: ['800px', '640px'],
	    content: '/page/guke_zz.html'
	    ,zIndex: 1003 //重点1
        ,success: function(layero){
          parent.layer.setTop(layero); //重点2
        }
	  });
});
        
   table.render({
    elem: '#lsxp'
    ,height: 440
    ,url:'/json/lsxp.json'
    ,page: true //开启分页
    ,title: '顾客数据表'
    ,cols: [[
      {field: 'id', title: '品种代码', width:100, sort: true}
      ,{field: 'username', title: '商品名称', width:100}
      ,{field: 'sex', title: '零售单价', width:100, sort: true}
      ,{field: 'city', title: '助记码', width:100} 
      ,{field: 'sign', title: '版型名', width: 100}
      ,{field: 'experience', title: '颜色', width: 100, sort: true}
      ,{field: 'score', title: '规格', width: 100}
      ,{field: 'classify', title: '商品代码', width: 100}
      ,{field: 'wealth', title: '分销单价', width: 100}
      ,{field: 'classify', title: '实际库存', width: 100}
      ,{field: 'wealth', title: '已配库存', width: 100}
    ]]
  });
  
  //监听行单击事件（单击为：row  双击事件为：rowDouble）
  table.on('rowDouble(lsxp)', function(obj){
    var data = obj.data;
    layer.alert(JSON.stringify(data), {
      title: '当前行数据'
    });
    obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');//标注选中样式
	  console.log(obj.data); //得到当前行数据
	  console.log(obj.data.username);//得到当前行组织编号数据
  });
  
  
  
  table.render({//明细
    elem: '#lsxp_mx'
    ,height: 500
    ,url:'/json/lsxp_mx.json'
    ,title: '零售小票明细数据表'
    ,cols: [[
      {field: 'id', title: '商品代码', width:100, sort: true}
      ,{field: 'username', title: '商品名称', width:100}
      ,{field: 'sex', title: '生产成本', width:100, sort: true}
      ,{field: 'city', title: '助记码', width:100} 
      ,{field: 'sign', title: '序号', width: 100}
      ,{field: 'experience', title: '颜色', width: 100, sort: true}
      ,{field: 'score', title: '规格', width: 100}
      ,{field: 'classify', title: '商品代码', width: 100}
      ,{field: 'wealth', title: '分销单价', width: 100}
      ,{field: 'classify', title: '实际库存', width: 100}
      ,{field: 'wealth', title: '已配库存', width: 100}
    ]]
  });
  
  
  table.render({//付款
    elem: '#lsxp_fk'
    ,height: 500
    ,url:'/json/lsxp_fk.json'
    ,title: '零售小票付款数据表'
    ,cols: [[
      {field: 'id', title: '行号', width:100, sort: true}
      ,{field: 'username', title: '付款方式名称', width:100}
      ,{field: 'sex', title: '币种名称', width:100, sort: true}
      ,{field: 'city', title: '卡号', width:100} 
      ,{field: 'sign', title: '原币金额', width: 100}
      ,{field: 'experience', title: '汇率', width: 100, sort: true}
      ,{field: 'score', title: '付款金额', width: 100}
      ,{field: 'classify', title: '实得率', width: 100}
      ,{field: 'wealth', title: '参考号', width: 100}
      ,{field: 'classify', title: '流水号', width: 100}
      ,{field: 'wealth', title: '已配库存', width: 100}
    ]]
  });  
  
   table.render({//唯一码
    elem: '#lsxp_wym'
    ,height: 500
    ,url:'/json/lsxp_wym.json'
    ,title: '零售小票唯一码数据表'
    ,cols: [[
      {field: 'id', title: '商品唯一码', sort: true}
      ,{field: 'username', title: '数量'}
    ]]
  }); 
  
  table.render({//促销
    elem: '#lsxp_cx'
    ,height: 500
    ,url:'/json/lsxp_cx.json'
    ,title: '零售小票促销策略数据表'
    ,cols: [[
      {field: 'id', title: '行号', sort: true}
      ,{field: 'username', title: '策略编号'}
      ,{field: 'sex', title: '策略名称', }
    ]]
  });  
  
  
  
  
  
  
  
  
  
  
  

        
    });